let fs = require('fs');
let buf = '';

process.stdin.on('readable', function() {
    let chunk = process.stdin.read();
    if (chunk) buf += chunk.toString();
});

let dfs = (t, book, n, a) => {
    if (t === n) {
        let s = "";
        for (let v of a) {
            s += `${v} `;
        }
        console.log(s);
        return;
    }
    for (let i = 1; i <= n; ++i) {
        if (book[i] === false) {
            book[i] = true;
            a.push(i);
            dfs(t + 1, book, n, a);
            a.pop();
            book[i] = false;
        }
    }
}

process.stdin.on('end', function() {
    let n = parseInt(buf.split("\n")[0]);
    let book = [], a = [];
    for (let i = 0; i <= n; ++i) book[i] = false;
    dfs(0, book, n, a);
});